package com.luyuan.web.controller.gallery;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.luyuan.common.annotation.Log;
import com.luyuan.common.core.controller.BaseController;
import com.luyuan.common.core.domain.AjaxResult;
import com.luyuan.common.enums.BusinessType;
import com.luyuan.gallery.domain.ExhiArtist;
import com.luyuan.gallery.service.IExhiArtistService;
import com.luyuan.common.utils.poi.ExcelUtil;
import com.luyuan.common.core.page.TableDataInfo;

/**
 * 艺术家Controller
 * 
 * @author luyuan
 * @date 2025-11-13
 */
@RestController
@RequestMapping("/gallery/artist")
public class ExhiArtistController extends BaseController {
    @Autowired
    private IExhiArtistService exhiArtistService;

    /**
     * 查询艺术家列表
     */
    @PreAuthorize("@ss.hasPermi('gallery:artist:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExhiArtist exhiArtist) {
        startPage();
        List<ExhiArtist> list = exhiArtistService.selectExhiArtistList(exhiArtist);
        return getDataTable(list);
    }

    /**
     * 导出艺术家列表
     */
    @PreAuthorize("@ss.hasPermi('gallery:artist:export')")
    @Log(title = "艺术家", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ExhiArtist exhiArtist) {
        List<ExhiArtist> list = exhiArtistService.selectExhiArtistList(exhiArtist);
        ExcelUtil<ExhiArtist> util = new ExcelUtil<ExhiArtist>(ExhiArtist.class);
        util.exportExcel(response, list, "艺术家数据");
    }

    /**
     * 获取艺术家详细信息
     */
    @PreAuthorize("@ss.hasPermi('gallery:artist:query')")
    @GetMapping(value = "/{artistId}")
    public AjaxResult getInfo(@PathVariable("artistId") Long artistId) {
        return success(exhiArtistService.selectExhiArtistByArtistId(artistId));
    }

    /**
     * 新增艺术家
     */
    @PreAuthorize("@ss.hasPermi('gallery:artist:add')")
    @Log(title = "艺术家", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExhiArtist exhiArtist) {
        return toAjax(exhiArtistService.insertExhiArtist(exhiArtist));
    }

    /**
     * 修改艺术家
     */
    @PreAuthorize("@ss.hasPermi('gallery:artist:edit')")
    @Log(title = "艺术家", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExhiArtist exhiArtist) {
        return toAjax(exhiArtistService.updateExhiArtist(exhiArtist));
    }

    /**
     * 删除艺术家
     */
    @PreAuthorize("@ss.hasPermi('gallery:artist:remove')")
    @Log(title = "艺术家", businessType = BusinessType.DELETE)
    @DeleteMapping("/{artistIds}")
    public AjaxResult remove(@PathVariable Long[] artistIds) {
        return toAjax(exhiArtistService.deleteExhiArtistByArtistIds(artistIds));
    }
}
